package drds.binlog.binlog_task;

import drds.binlog.common.Authors;
import drds.binlog.common.StorageBatchMode;
import drds.common.Author;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;


@Author(name = Authors.LI_YANG)
@Slf4j
public class BinlogTaskFactory
{


    public IBinlogTask config(String destination, String json)
    {
        log.info("创建destination:[{}]" + BinlogTask.class.getSimpleName(), destination);
        BinlogTaskInfo binlogTaskInfo = getBinlogTaskInfo(destination);
        return new BinlogTask(binlogTaskInfo);
    }

    public BinlogTaskInfo getBinlogTaskInfo(String destination)
    {
        BinlogTaskInfo binlogTaskInfo = new BinlogTaskInfo();
        binlogTaskInfo.setBinlogTaskId(1l);
        binlogTaskInfo.setDestination(destination);
        binlogTaskInfo.setDesc("drds binlog服务");
        Parameter parameter = new Parameter();
        parameter.setStorageBatchMode(StorageBatchMode.item_size);


        //
        List<SalveInfo> salveInfoList = new ArrayList<SalveInfo>();
        parameter.setSalveInfoList(salveInfoList);
        SalveInfo salveInfo = new SalveInfo();
        salveInfo.setHost("192.168.1.107");
        salveInfo.setPort(3308);
        salveInfo.setUsername("root");
        salveInfo.setPassword("123456");
        salveInfo.setSlaveId(1);
        salveInfoList.add(salveInfo);
        //


        binlogTaskInfo.setParameter(parameter);

        binlogTaskInfo.setDesc("xxx");
        return binlogTaskInfo;
    }


}
